@extends('admin::public.base')
<style>
#user_list{
    display:none;
}
.layui-layer-content{
    position: relative;
}
body{
    overflow-y: scroll
}
.layui-table-cell .layui-form-checkbox[lay-skin=primary], .layui-table-cell .layui-form-radio[lay-skin=primary]{
    top:6px!important;
}
.user_btn{
    text-align: center;
    position: absolute;
    width: 100%;
    bottom: 10px;
}
.user_box{
    display:none;
}
.user_box .box{
    margin-right: 10px;
    display: inline-block;
    position: relative;
    background: #108cee;
    padding: 0px 10px;
    font-size: 12px;
    border-radius: 5px;
}
.user_box .box span{
    color:#ffffff;
}
.user_box .box em{
    position: absolute;
    right: -5px;
    font-size: 14px;
    display: inline-block;
    background: red;
    color: #fff;
    top: -5px;
    height: 15px;
    width: 15px;
    text-align: center;
    line-height: 15px;
    border-radius: 50%;
    cursor: pointer;
}
.send_time{
    display:none;
}
</style>
@section('content')
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <header class="title">消息详情</header>
        </div>
        <div class="layui-card-body">
            <div action="" class="layui-form">
                <div class="layui-form-item">
                    <label for="" class="layui-form-label layui-required">消息类型</label>
                    <div class="layui-input-block">
                        <select name="type" id="" disabled>
                            @foreach ($types as $key=>$item)
                                <option value="{{$key}}" @if($key==$msg->id) selected @endif>{{$item}}</option>
                            @endforeach
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label layui-required">消息标题</label>
                    <div class="layui-input-block">
                        <input class="layui-input" type="text" disabled value="{{$msg->title}}" autocomplete="off" name="title" id="title" placeholder="请输入消息标题">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label layui-required">消息内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" id="content" disabled class="layui-textarea">{{$msg->content}}</textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">消息图片</label>
                    <div class="layui-input-block">
                        <div class="app-image-box">
                            @if ($msg->logo)
                                <div class="box">
                                    <input type="hidden" name="logo" value="{{$msg->logo}}">
                                    <img src="{{$msg->logo}}" alt="">
                                    <em onclick="delImage(this)" title="删除">×</em>
                                </div>
                            @endif
                        </div>
                        <div class="app-btn-file"><input type="file" disabled name="logo" accept="image/*" class="app-image"  onchange="imageCallBack(this)"/>
                        <div class="app-btn-name"><p class="fa fa-folder-open-o"></p><h1>上传图片</h1></div></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label layui-required">发送群体</label>
                    <div class="layui-input-block">
                        <input type="radio" name="user_type" disabled @if($msg->user_type==1) checked @endif value="1" title="全部用户" lay-filter="user_type">
                        <input type="radio" name="user_type" disabled @if($msg->user_type==2) checked @endif value="2" title="部分用户" lay-filter="user_type">
                    </div>
                </div>
                <div class="layui-form-item user_box">
                    <div class="layui-input-block" style="padding: 10px;border:1px solid #e6e6e6;">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label layui-required">发送方式</label>
                    <div class="layui-input-block">
                        <input type="radio" name="send_type" disabled @if($msg->create_time==$msg->send_time) checked @endif value="1" title="即时" lay-filter="send_type">
                        <input type="radio" name="send_type" disabled @if($msg->create_time<$msg->send_time) checked @endif value="2" title="定时" lay-filter="send_type">
                    </div>
                </div>
                <div class="layui-form-item send_time">
                    <div class="layui-input-block " >
                        <div class="layui-input-inline" style="width:auto;padding: 5px 0px;">
                            选择时间：
                        </div>
                        <div class="layui-input-inline">
                            <input type="text" disabled value="{{$msg->send_time}}" name="send_time" class="layui-input" id="send_time">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">消息链接</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" disabled value="{{$msg->url}}" autocomplete="off" name="url" id="url" placeholder="请输入完整的url链接">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">消息详情</label>
                    <div class="layui-input-block">
                        <textarea name="detail" id="detail" disabled class="layui-textarea">{{$msg->detail}}</textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <a href="javascript:history.back(-1);" class="layui-btn layui-btn-primary" >返 回</a>
                    </div>
                </div>
                <div id="user_list">
                    <div class="layui-header">
                        <div class="layui-card-header layuiadmin-card-header-auto">
                            <div class="layui-input-inline">
                                <input type="text" name="filter" value="" id="filter" autocomplete="off" placeholder="请输入用户昵称|手机号" class="layui-input layui-search">
                            </div>
                            <div class="layui-input-inline">
                                <button type="submit" class="layui-btn layui-btn-search" onclick="reload();">查询</button>
                            </div>
                        </div>
                    </div>
                    <table id="dataTable" class="layui-hide" lay-filter="dataTable"></table>
                    <div class="layui-form-item user_btn">
                        <button type="submit" class="layui-btn" onclick="user_confirm();">确 认</button>
                        <a href="javascript:layer.closeAll();" class="layui-btn layui-btn-primary" >取 消</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('script')
<script src="/static/common/plugins/kindeditor/kindeditor-all.js"></script>
<script src="/static/common/plugins/kindeditor/lang/zh-CN.js"></script>
    <script>
        layui.use(['layer','form','table','laydate'],function () {
            var form = layui.form;
            var layer = layui.layer;
            var table = layui.table;
            var laydate = layui.laydate;
            var user = {!!$group!!};
            var image = "";
            if({{$msg->user_type}}==2){
                $('.user_box').show();
            }
            $('.send_time').show();
            //用户初始化
            window.user_init = function(){
                var ids = user.map(function (item) {
            　　　　 return item['id'];
                });
                var html = '';
                for(var i=0;i<user.length;i++){
                    html += '<div class="box"><span data-id="'+user[i].id+'">'+user[i].nickname+'</span></div>';
                }
                $('.user_box').find('.layui-input-block').append(html);
            }
            user_init();
            //富文本编辑器
            window.editor = KindEditor.create('#detail', {
                height: '300px',
                width:'100%',
                themeType: 'default',
                allowPreviewEmoticons: false,
                allowImageUpload: true,
                allowFileManager: true,
                uploadJson: "{{ route('admin.editorUpload') }}",
                afterBlur: function(){ this.sync(); },
                afterUpload: function (url) {
                    this.sync();
                },
                items: [
                    'undo', 'redo','|','justifyleft', 'justifycenter', 'justifyright',
                    'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent','|',
                    'fontname', 'fontsize','forecolor', 'hilitecolor', 'bold',
                    'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat','|','image', 'multiimage',
                    'emoticons','link', 'unlink'
                ]
            });
        });
    </script>
@endsection

